var api = require('../../utils/api.js');
var app = getApp();
Page({
    data: {
      list:[]
    },
    currentPageNumber: 1,
    onLoad() {
      var that=this;
      api.get({
        url: 'wxapp/index/getbanner',
        data: {},
        success: data => {
           console.log(data);
           that.setData({
             banner:data.data
           })
        }
 
      });

    },
    onShow() {
      var that=this;
      api.get({
        url: 'wxapp/index/indexlist',
        data: {},
        success: data => {
           console.log(data);
           that.setData({
             list:data.data
           })
        }
 
      });



    api.get({
        url: 'wxapp/user/getUserInfo',
        data: {},
        success: data => {
          console.log(data);
          var user = data.data;
          that.setData({
            user: user
          })
  
          if (!user.agentid) {
  
            wx.showModal({
              title: '提示',
              content: '你还未进行认证!',
              showCancel: false,
              success(res) {
                if (res.confirm) {
                  wx.navigateTo({
                    url: '/pages/rz/index',
                  })
                }
              }
            })
          }
  
          if (!user.team_id) {
  
              wx.showModal({
                title: '提示',
                content: '你还未进行绑定!',
                showCancel: false,
                success(res) {
                  if (res.confirm) {
                    wx.navigateTo({
                      url: '/pages/index/select',
                    })
                  }
                }
              })
            }
  
  
        }
      });

    },


    nexturl(ret){
      console.log(ret);
      var url=ret.currentTarget.dataset.url;
      
      wx.navigateTo({
        url: url
      })

    },


    /**
     * 上拉刷新
     */
    pullUpLoad() {
      
    },
 
    previewImage(e) {
        wx.previewImage({
            current: '', // 当前显示图片的http链接
            urls: [e.currentTarget.dataset.previewUrl] // 需要预览的图片http链接列表
        });

    },
    onShareAppMessage() {
        return {
            title: '好玩的,都在这儿~~',
            path: '/pages/index/index'
        }
    }

});
